- @title = "#{t('groups.search.results_heading')} (#{@groups.count})"

- if @groups.any?
  = pagination @groups

  %table.table.group-list
    %tr
      %th
      %th= t('groups.table.group_name')
      %th= t('groups.table.leader')
      %th= t('groups.table.member_count')
      %th= t('groups.table.category')

    - @groups.each do |group|
      %tr.row-with-avatar{class: group.hidden? ? 'grayed' : ''}
        %td.avatar
          = group_avatar_tag(group)
        %td.group
          = link_to group.name, group
          - if group.private?
            %span.label.label-warning
              = icon 'fa fa-lock'
              = t('groups.private.label')
          - if group.hidden?
            %span.label.label-danger
              = icon 'fa fa-eye-slash'
              = t('groups.hidden.label')
        %td
          - if (leaders = group.leaders.to_a).any?
            = safe_join(leaders.map { |p| link_to(p.try(:name), p) }, ', ')
        %td
          = group.memberships.count
        %td
          = link_to group.category, groups_path(category: group.category)
      - if group.description.present?
        %tr.description{class: group.hidden? ? 'grayed hidden-group' : ''}
          %td
          %td{colspan: 3}
            = group.description

  = pagination @groups

- else
  %p
    %em= t('groups.no_groups_found')

- if @logged_in.admin?(:manage_groups) and @hidden_groups.any? and not params[:include_hidden]
  %p
    = link_to t('groups.show_hidden.button', count: @hidden_groups.count), groups_path(name: params[:name], include_hidden: true, page: nil), class: 'btn btn-warning'

